package com.ruoyi.wetest.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wetest.domain.WetestStressStatistics;
import com.ruoyi.wetest.service.IWetestStressStatisticsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 压测上报数据统计Controller
 * 
 * @author ruoyi
 * @date 2024-04-30
 */
@RestController
@RequestMapping("/wetest/statistics")
public class WetestStressStatisticsController extends BaseController
{
    @Autowired
    private IWetestStressStatisticsService wetestStressStatisticsService;

    /**
     * 查询压测上报数据统计列表
     */
    @PreAuthorize("@ss.hasPermi('wetest:statistics:list')")
    @GetMapping("/list")
    public TableDataInfo list(WetestStressStatistics wetestStressStatistics)
    {
        startPage();
        List<WetestStressStatistics> list = wetestStressStatisticsService.selectWetestStressStatisticsList(wetestStressStatistics);
        return getDataTable(list);
    }

    /**
     * 导出压测上报数据统计列表
     */
    @PreAuthorize("@ss.hasPermi('wetest:statistics:export')")
    @Log(title = "压测上报数据统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WetestStressStatistics wetestStressStatistics)
    {
        List<WetestStressStatistics> list = wetestStressStatisticsService.selectWetestStressStatisticsList(wetestStressStatistics);
        ExcelUtil<WetestStressStatistics> util = new ExcelUtil<WetestStressStatistics>(WetestStressStatistics.class);
        util.exportExcel(response, list, "压测上报数据统计数据");
    }

    /**
     * 获取压测上报数据统计详细信息
     */
    @PreAuthorize("@ss.hasPermi('wetest:statistics:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(wetestStressStatisticsService.selectWetestStressStatisticsById(id));
    }

    /**
     * 新增压测上报数据统计
     */
    @PreAuthorize("@ss.hasPermi('wetest:statistics:add')")
    @Log(title = "压测上报数据统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WetestStressStatistics wetestStressStatistics)
    {
        return toAjax(wetestStressStatisticsService.insertWetestStressStatistics(wetestStressStatistics));
    }

    /**
     * 修改压测上报数据统计
     */
    @PreAuthorize("@ss.hasPermi('wetest:statistics:edit')")
    @Log(title = "压测上报数据统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WetestStressStatistics wetestStressStatistics)
    {
        return toAjax(wetestStressStatisticsService.updateWetestStressStatistics(wetestStressStatistics));
    }

    /**
     * 删除压测上报数据统计
     */
    @PreAuthorize("@ss.hasPermi('wetest:statistics:remove')")
    @Log(title = "压测上报数据统计", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wetestStressStatisticsService.deleteWetestStressStatisticsByIds(ids));
    }
}
